#include<stdio.h>

int main(){
	int a,b,sign,gcd=1;
	scanf("%d %d",&a,&b);
	int min=(a>=b)?b:a;
	int max=(a>=b)?a:b; 
	if(a==0||b==0) printf("%d",max);
	else{
		for(sign=1;sign<=a;sign++){
		if(a%sign==0&&b%sign==0){
			gcd=sign;
			}
		}
		printf("%d",gcd);
	}
	return 0;
}
